package com.ssy.lingxi.purchase.entity.tender;

import com.fasterxml.jackson.annotation.JsonManagedReference;
import lombok.Getter;
import lombok.Setter;

import javax.persistence.*;
import java.io.Serializable;
import java.util.List;

/**
 * 招标实体类
 * @author jw.chen
 * @version 2.0.0
 * @date 2021/3/1
 */
@Getter
@Setter
@Entity
@Table(schema = "public", name = "purchase_invite_tender")
public class InviteTender implements Serializable {
    private static final long serialVersionUID = 4788094892531489865L;
    /**
     * 主键id
     */
    @Id
    @GeneratedValue(strategy= GenerationType.SEQUENCE, generator="invite_tender_seq")
    @SequenceGenerator(sequenceName="purchase_invite_tender_seq", name="invite_tender_seq",allocationSize = 1)
    private Long id;

    /**
     * 招标编号
     */
    @Column(columnDefinition = "varchar(20)", nullable = false)
    private String code;

    /**
     * 招标外部状态: InviteTenderOutStatusEnum.class
     */
    @Column(columnDefinition = "int", nullable = false)
    private Integer inviteTenderOutStatus = 1;

    /**
     * 招标内部状态: InviteTenderInStatusEnum.class
     */
    @Column(columnDefinition = "int", nullable = false)
    private Integer inviteTenderInStatus = 1;

    /**
     * 采购类型: 1-单次采购;2-协议采购;
     */
    @Column(columnDefinition = "int", nullable = false)
    private Integer purchaseType;

    /**
     * 招标项目名
     */
    @Column(columnDefinition = "varchar(60)", nullable = false)
    private String projectName;

    /**
     * 招标摘要
     */
    @Column(columnDefinition = "varchar(200)", nullable = false)
    private String remark;

    /**
     * 项目预算
     */
    @Column(columnDefinition = "decimal")
    private Double budget;

    /**
     * 是否不限制区域
     */
    @Column(columnDefinition = "boolean", nullable = false)
    private Boolean isAllArea = true;

    /**
     * 归属地市
     */
    @JsonManagedReference
    @OneToMany(mappedBy = "inviteTender", cascade={CascadeType.PERSIST, CascadeType.MERGE, CascadeType.REMOVE})
    private List<InviteTenderArea> inviteTenderAreaList;

    /**
     * 招标物料
     */
    @JsonManagedReference
    @OneToMany(mappedBy = "inviteTender", cascade={CascadeType.PERSIST, CascadeType.MERGE, CascadeType.REMOVE})
    private List<InviteTenderMateriel> materielList;

    /**
     * 投标开始时间
     */
    @Column(columnDefinition = "int8", nullable = false)
    private Long inviteTenderStartTime;

    /**
     * 投标结束时间
     */
    @Column(columnDefinition = "int8", nullable = false)
    private Long inviteTenderEndTime;

    /**
     * 期望交付日期
     */
    @Column(columnDefinition = "int8", nullable = false)
    private Long hopeDate;

    /**
     * 目标价
     */
    @Column(columnDefinition = "decimal")
    private Double targetPrice;

    /**
     * 招标要求
     */
    @Column(columnDefinition = "varchar(200)")
    private String inviteTenderRequirement;

    /**
     * 招标文件
     */
    @JsonManagedReference
    @OneToMany(mappedBy = "inviteTender", cascade={CascadeType.PERSIST, CascadeType.MERGE, CascadeType.REMOVE})
    private List<InviteTenderFile> inviteTenderFile;

    /**
     * 报名开始时间
     */
    @Column(columnDefinition = "int8", nullable = false)
    private Long registerStartTime;

    /**
     * 报名结束时间
     */
    @Column(columnDefinition = "int8", nullable = false)
    private Long registerEndTime;

    /**
     * 报名要求
     */
    @Column(columnDefinition = "varchar(200)")
    private String registerRequirement;

    /**
     * 报名要求附件
     */
    @JsonManagedReference
    @OneToMany(mappedBy = "inviteTender", cascade={CascadeType.PERSIST, CascadeType.MERGE, CascadeType.REMOVE})
    private List<InviteTenderRegisterFile> registerFile;

    /**
     * 是否需要资格预审
     */
    @Column(columnDefinition = "boolean", nullable = false)
    private Boolean isQualificationCheck = true;

    /**
     * 提交资格预审开始时间
     */
    @Column(columnDefinition = "int8")
    private Long preCheckStartTime;

    /**
     * 提交资格预审结束时间
     */
    @Column(columnDefinition = "int8")
    private Long preCheckEndTime;

    /**
     * 预审要求
     */
    @Column(columnDefinition = "varchar(200)")
    private String preCheckRequirement;

    /**
     * 预审要求附件
     */
    @JsonManagedReference
    @OneToMany(mappedBy = "inviteTender", cascade={CascadeType.PERSIST, CascadeType.MERGE, CascadeType.REMOVE})
    private List<InviteTenderPreCheckFile> preCheckFile;

    /**
     * 评标开始时间
     */
    @Column(columnDefinition = "int8")
    private Long evaluationStartTime;

    /**
     * 评标结束时间
     */
    @Column(columnDefinition = "int8")
    private Long evaluationEndTime;

    /**
     * 评标要求
     */
    @Column(columnDefinition = "varchar(100)")
    private String evaluationRequirement;

    /**
     * 评标要求附件
     */
    @JsonManagedReference
    @OneToMany(mappedBy = "inviteTender", cascade={CascadeType.PERSIST, CascadeType.MERGE, CascadeType.REMOVE})
    private List<InviteTenderEvaluationFile> evaluationFile;

    /**
     * 是否在线评标
     */
    @Column(columnDefinition = "boolean", nullable = false)
    private Boolean isOnlineEvaluation = true;

    /**
     * 评标项模板
     */
    @Column(columnDefinition = "int8")
    private Long templateId;

    /**
     * 开标时间
     */
    @Column(columnDefinition = "int8", nullable = false)
    private Long openTenderTime;

    /**
     * 付款方式
     */
    @Column(columnDefinition = "varchar(100)")
    private String payType;

    /**
     * 交付地址id
     */
    @Column(columnDefinition = "int")
    private Integer deliverAddressId;

    /**
     * 交付地址
     */
    @Column(columnDefinition = "varchar(200)")
    private String deliverAddress;

    /**
     * 交付要求
     */
    @Column(columnDefinition = "varchar(100)")
    private String deliverRequirement;

    /**
     * 税费要求
     */
    @Column(columnDefinition = "varchar(100)")
    private String taxationRequirement;

    /**
     * 物流要求
     */
    @Column(columnDefinition = "varchar(100)")
    private String logisticsRequirement;

    /**
     * 包装要求
     */
    @Column(columnDefinition = "varchar(100)")
    private String packingRequirement;

    /**
     * 其他要求
     */
    @Column(columnDefinition = "varchar(100)")
    private String otherRequirement;

    /**
     * 招标方式：1-公开招标; 2-系统匹配; 3-邀请招标;
     */
    @Column(columnDefinition = "int", nullable = false)
    private Integer inviteTenderType;

    /**
     * 招标发布的商城
     */
    @JsonManagedReference
    @OneToMany(mappedBy = "inviteTender", cascade={CascadeType.PERSIST, CascadeType.MERGE, CascadeType.REMOVE})
    private List<InviteTenderShop> inviteTenderShopList;

    /**
     * 符合投标会员
     */
    @JsonManagedReference
    @OneToMany(mappedBy = "inviteTender", cascade={CascadeType.PERSIST, CascadeType.MERGE, CascadeType.REMOVE})
    private List<InviteTenderMember> memberList;

    /**
     * 是否抽取过评标专家
     */
    @Column(columnDefinition = "boolean")
    private Boolean isExistExpertExtract = false;

    /**
     * 评标专家抽取
     */
    @JsonManagedReference
    @OneToMany(mappedBy = "inviteTender", cascade={CascadeType.PERSIST, CascadeType.MERGE, CascadeType.REMOVE})
    private List<ExpertExtract> expertExtractList;

    /**
     * 评标附件
     */
    @JsonManagedReference
    @OneToMany(mappedBy = "inviteTender", cascade={CascadeType.PERSIST, CascadeType.MERGE, CascadeType.REMOVE})
    private List<InviteTenderEvaluationTenderFile> evaluationTenderFile;

    /**
     * 推荐会员
     */
    @JsonManagedReference
    @OneToMany(mappedBy = "inviteTender", cascade={CascadeType.PERSIST, CascadeType.MERGE, CascadeType.REMOVE})
    private List<EvaluationTenderRecommend> evaluationTenderRecommendList;

    /**
     * 会员信用积分
     */
    @Column(columnDefinition = "int")
    private Integer creditScore = 0;

    /**
     * 会员id
     */
    @Column(columnDefinition = "int8", nullable = false)
    private Long memberId;

    /**
     * 会员名称
     */
    @Column(columnDefinition = "varchar(50)", nullable = false)
    private String memberName;

    /**
     * 会员角色id
     */
    @Column(columnDefinition = "int8", nullable = false)
    private Long memberRoleId;

    /**
     * 会员角色名称
     */
    @Column(columnDefinition = "varchar(50)", nullable = false)
    private String memberRoleName;

    /**
     * 用户id
     */
    @Column(columnDefinition = "int8", nullable = false)
    private Long userId;

    /**
     * 用户名称
     */
    @Column(columnDefinition = "varchar(50)", nullable = false)
    private String userName;

    /**
     * 创建时间
     */
    @Column(columnDefinition = "int8", nullable = false)
    private Long createTime = System.currentTimeMillis();

    /**
     * 发布时间
     */
    @Column(columnDefinition = "int8")
    private Long publishTime;

    /**
     * 废标时间
     */
    @Column(columnDefinition = "int8")
    private Long discardTime;

    /**
     * 废标原因
     */
    @Column(columnDefinition = "varchar(100)")
    private String discardRemark;

    /**
     * 中标理由
     */
    @Column(columnDefinition = "varchar(100)")
    private String winTenderReason;

    /**
     * 中标附件
     */
    @JsonManagedReference
    @OneToMany(mappedBy = "inviteTender", cascade={CascadeType.PERSIST, CascadeType.MERGE, CascadeType.REMOVE})
    private List<WinTenderFile> winTenderFile;

    /**
     * 是否发布中标公示
     */
    @Column(columnDefinition = "boolean")
    private Boolean winTenderAnnounce = true;

    /**
     * 中标公示内容
     */
    @Column(columnDefinition = "text")
    private String winTenderAnnounceContent;

    /**
     * 是否发送中标通知
     */
    @Column(columnDefinition = "boolean")
    private Boolean winTenderNotice;

    /**
     * 中标通知内容
     */
    @Column(columnDefinition = "text")
    private String winTenderNoticeContent;

    /**
     * 是否发送感谢函
     */
    @Column(columnDefinition = "boolean")
    private Boolean winTenderThanks;

    /**
     * 感谢函内容
     */
    @Column(columnDefinition = "text")
    private String winTenderThanksContent;

    /**
     * 中标公示
     */
    @JsonManagedReference
    @OneToMany(mappedBy = "inviteTender", cascade={CascadeType.PERSIST, CascadeType.MERGE, CascadeType.REMOVE})
    private List<WinTenderAnnounceFile> winTenderAnnounceFile;

    /**
     * 中标通知
     */
    @JsonManagedReference
    @OneToMany(mappedBy = "inviteTender", cascade={CascadeType.PERSIST, CascadeType.MERGE, CascadeType.REMOVE})
    private List<WinTenderNoticeFile> winTenderNoticeFile;

    /**
     * 是否完成招标
     */
    @Column(columnDefinition = "boolean")
    private Boolean isFinish = false;

    /**
     * 招投标流程任务id
     */
    @Column(columnDefinition = "varchar(100)")
    private String purchaseInviteTenderTaskId;

    /**
     * 新增招标流程任务id
     */
    @Column(columnDefinition = "varchar(100)")
    private String purchaseAddTenderTaskId;

    /**
     * 定标流程任务id
     */
    @Column(columnDefinition = "varchar(100)")
    private String purchaseFinishTenderTaskId;


    /**
     * 发布商城类型 1.企业商城 6.采购门户
     * （招标方式不为公开招标也需要记录用于区分b2b商城与采购门户中的采购能力-220418）
     */
    @Column(columnDefinition = "int default 6",nullable = false)
    private Integer shopType;

}
